# U-Boot: TrimSlice
# Maintainer: Kevin Mihelich <kevin@archlinuxarm.org>

buildarch=4

pkgname=uboot-trimslice
pkgver=2016.11
pkgrel=1
pkgdesc="U-Boot for TrimSlice"
arch=('armv7h')
url='http://www.denx.de/wiki/U-Boot/WebHome'
license=('GPL')
install=$pkgname.install
backup=('boot/boot.txt' 'boot/boot.scr')
depends=('mtd-utils')
makedepends=('bc' 'dtc' 'git' 'cbootimage')
source=("ftp://ftp.denx.de/pub/u-boot/u-boot-${pkgver}.tar.bz2"
        'git+https://github.com/NVIDIA/cbootimage-configs.git'
        '0001-arch-linux-arm-modifications.patch'
        'boot.txt'
        'mkscr')
md5sums=('ca1f6e019d08aff8d0ca1beb2e66737d'
         'SKIP'
         '6f1b2989f6c246bc48e7120657d1a2dd'
         '6a8ce2258f0c23d6e8fe7418e3fd1c24'
         '021623a04afd29ac3f368977140cfbfd')

prepare() {
  cd u-boot-${pkgver}
  git apply ../0001-arch-linux-arm-modifications.patch
}

build() {
  cd u-boot-${pkgver}

  unset LDFLAGS

  make distclean 
  make trimslice_config
  make
}

package() {
  mkdir -p "${pkgdir}"/boot

  install -Dm644 boot.txt "${pkgdir}"/boot/boot.txt
  u-boot-${pkgver}/tools/mkimage -A arm -O linux -T script -C none -n "U-Boot boot script" -d boot.txt "${pkgdir}"/boot/boot.scr
  install -Dm755 mkscr "${pkgdir}"/boot/mkscr

  cd cbootimage-configs/tegra20/compulab/trimslice
  ln -s ${srcdir}/u-boot-${pkgver}/u-boot-dtb-tegra.bin u-boot.bin
  ./build.sh

  install -m644 trimslice-mmc.img trimslice-spi.img "${pkgdir}"/boot
}
